<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script src="./js/jquery-1.12.2.min.js"></script>
  <script>
  var mydata01=[
    {
      name:'BOC',
      A_CNT:11,
      B_CNT:12
    },
    {
      name:'BOC',
      C_CNT:13,
      D_CNT:14
    },
    {
      name:'DDC',
      A_CNT:11
    },
  ]
  //将以上数组合并为,相同属性名对象合并为一组对象,没组对象有四组数据,没有就补0/"-"
  // var mydata01=[
  //   {
  //     name:'BOC',
  //     A_CNT:11,
  //     B_CNT:12,
  //     C_CNT:13,
  //     D_CNT:14
  //   },
  //   {
  //     name:'DDC',
  //     A_CNT:11,
  //     B_CNT:0,
  //     C_CNT:0,
  //     D_CNT:0
  //   },
  // ]
var new_arr=[]
  function mergeArr(arr,code,what){
    var what=what || "-";
    var key_obj=[]
    var key_code={
      name:1,
      A_CNT:1,
      B_CNT:1,
      C_CNT:1,
      D_CNT:1
      }
      arr.forEach(function(item,i){
        if(!key_obj[item[code]]){
          new_arr.push(item)
          key_obj[item[code]]=1
        }else{
          key_obj[item[code]]++
        }
        for(var j=0;j<new_arr.length;j++){
          if(item[code]==new_arr[j][code]){
            new_arr[j]=$.extend(item,new_arr[j])
          }
        }
      })
      new_arr=new_arr.map(function(item){
        if(Object.keys(item).length<Object.keys(key_code).length){
          for(var it in key_code){
            if(!item[it]){
              item[it]=what;
            }
          }
        }
        return item;
      })
      return new_arr
  }
  mergeArr(mydata01,'name','-')
  console.log('new_arr',new_arr);
  </script>
</body>
</html>